/**
 * 
 */
package cn.gov.msa.ws;

import javax.jws.WebService;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import cn.gov.msa.service.VerifyService;



@WebService(endpointInterface = "cn.gov.msa.ws.GahService")
public class GahServiceImpl implements GahService {

    /*初始化Spring容器*/  
    ApplicationContext ctx = null; 
    
	@Override
	public String stirnggetData(String businessCode, String params) throws Exception {
		String result = "";
//		System.err.println(params);
		
		try{
			if(ctx == null)
				ctx = new ClassPathXmlApplicationContext(new String[]{"applicationContext.xml"});  
			
			switch (businessCode) {
			
				//系统业务
				case "DKS100":				// 业务查询
					result = BusinessService.selectData(ctx, params);
					break;
				case "DKS101":				// 查询数据字典
					result = DictService.dictionary(ctx, params);
					break;
				case "DKS102":				// 行政许可提交材料
					result = BusinessService.getMaterial(ctx, params);
					break;
				case "DKS103":				// 查询海事机构
					result = OrgService.getorg(ctx, params);
					break;
				case "DKS104":
					result = OrgService.getChildOrg(ctx, params);
					break;
				case "DKS105":              // 查询常用机构
					result = OrgService.getOrg(ctx, params);
					break;
				case "DKS105_1":            // 查询常用机构(旧)
					result = OrgService.getOrg1(ctx, params);
					break;
				case "DKS120":				// 许可项目查询
					result = DeclareServcie.list(ctx, params);
					break;
				case "DKS108":				// 材料补正信息
					result = BusinessService.selectCorrection(ctx, params);
					break;
				case "DKS123":				// 文件下载
					result = FileService.down(ctx, params);
					break;
				case "DKS124":				// 文书查询
					result = BusinessService.amanuensis(ctx, params);
					break;
				case "DKS125":				// 申请单文书查询
					result = BusinessService.amanuensisbyid(ctx, params);
					break;
				case "DKS126":				// 水道查询
					result = BusinessService.waterwayData(ctx, params);
					break;
				case "DKS127":				// 航标查询
					result = BusinessService.markData(ctx, params);
					break;
				case "DKS206":				// 详细查询  --- 打捞或者拆除沿海水域内沉船沉物许可
					result = BusinessService.getDetail(ctx, params);
					break;
				case "DKS207":				// 查询当前公司已备案的海事机构
					result = BusinessService.selectCompanyOrg(ctx, params);
					break;

					
				case "DKU101":				// 业务申报
					result = BusinessService.saveData(ctx, params);
					break;
				case "DKU603":				// 文件上传
					result = FileService.upload(ctx, params);
					break;
				case "DKU604":				//删除申请单
					result = BusinessService.deleteapply(ctx, params);
					break;
				case "DKU605":				//业务评价
					result = BusinessService.saveComment(ctx, params);
					break;
				case "DKU303":				//预约查询
					result = ReserveService.setData(ctx, params);
					break;
				case "DKU303_1":			//预约取消
					result = ReserveService.deleteDate(ctx, params);
					break;
				case "DKU303_2":			//预约项目查询
					result = ReserveService.setItem(ctx, params);
					break;
				case "DKU303_3":			//申请预约
					result = ReserveService.insertData(ctx, params);
					break;	
				case "DKU303_4":			//申请预约
					result = ReserveService.getNum(ctx, params);
					break;
					

				case "DKU201":				//问卷查询
					result = QuestionService.setData(ctx, params);
					break;
				case "DKU201_1":			//问卷问题查询
					result = QuestionService.setqData(ctx, params);
					break;
				case "DKU201_2":			//问卷问题提交
					result = QuestionService.submit(ctx, params);
					break;
					
				case "DKU401":				//常见问题查询
					result = QuestionsService.setData(ctx, params);
					break;
				
				case "DLU101":				//查询政务流程
					result = DeclareServcie.list(ctx, params);
					break;
				case "DLU101_1":			//查询政务详情
					result = DeclareServcie.getguideinfo(ctx, params);
					break;
				case "DLU101_2":			//查询政务详情表格文件
					result = DeclareServcie.guidetable(ctx, params);
					break;
				case "DLU101_3":			//查询政务详情样例文件
					result = DeclareServcie.guidestyle(ctx, params);
					break;
					
					
				case "ZSK101":				//知识库查询
					result = RepositoryService.selectData(ctx, params);
					break;
				case "ZSK101_1":			//增加次数
					result = RepositoryService.addViewCount(ctx, params);
					break;

					
				case "DKU301":				//咨询投诉
					result = ConsultingService.setData(ctx, params);
					break;
				case "DKU301_1":			//咨询投诉新建
					result = ConsultingService.addConsulting(ctx, params);
					break;

					
				case "DKS221" :             //公告
					result = NoticeServcie.list(ctx, params);
					break;
				case "DKS221_1" :           //公告详细
					result = NoticeServcie.info(ctx, params);
					break;	
				case "DKS221_2" :           //公告列表
					result = NoticeServcie.allList(ctx, params);
					break;		
					

				case "FHS101":			//船舶查询列表
					result = SystemService.queryShip(params);
					break;
				case "FHS102":			//泊位查询列表
					result = SystemService.queryBerth(params);
					break;
				case "FHS103":			//校验
					result = SystemService.check(params);
					break;
				case "FHS104":			//获取校验信息
					result = SystemService.queryVerify(ctx,params);
					break;
				case "FHS110":			//港口查询列表
					result = SystemService.queryPort(ctx, params);
					break;
				case "FHS111":			//(本地)增加船舶
					result = SystemService.addLocalShip(ctx, params);
					break;
				case "FHS112":			//(本地)获取船舶
					result = SystemService.getLocalShip(ctx, params);
					break;
				case "GSS101":			//政务公示列表
					result = ApplyService.list(ctx, params);
					break;	
				case "GSS102":			//政务公示列表(办结状态)
					result = ApplyService.listHadDone(ctx, params);
					break;	

				default:
					result = "{\"result\":\"0\", \"info\":\"未找到["+businessCode+"]服务接口！\"}";
					break;
			}
		}
		catch(Exception e){
			e.printStackTrace();
		}
		
		
		
		return result;
	}

	@Override
	public String hydInspect(String params) {
		System.out.println("###hydInspect### " + params);
		String result = "{\"result\":\"1\",\"resultinfo\":\"接口服务执行成功！\"}";
		try{
			if(ctx == null){
				ctx = new ClassPathXmlApplicationContext(new String[]{"applicationContext.xml"});
			}
			// 插入水上水下监督结果数据
			result = InspectService.hydInspect(ctx, params);
		} catch (Exception e) {
			e.printStackTrace();
			result = "{\"result\":\"0\",\"resultinfo\":\""+e.toString()+"\"}";
		}
		return result;
	}

	@Override
	public String hydInspectDelete(String param) {
		System.out.println("###hydInspectDelete### " + param);
		String result = "{\"result\":\"1\",\"resultinfo\":\"接口服务执行成功！\"}";
		try{
			result = InspectService.hydInspectDelete(ctx, param);
		} catch (Exception e) {
			e.printStackTrace();
			result = "{\"result\":\"0\",\"resultinfo\":\""+e.toString()+"\"}";
		}
		return result;
	}

	@Override
	public String adminInspect(String params) {
		System.out.println("###adminInspect### " + params);
		String result = "{\"result\":\"1\",\"resultinfo\":\"接口服务执行成功！\"}";
		try{
			if(ctx == null){
				ctx = new ClassPathXmlApplicationContext(new String[]{"applicationContext.xml"});
			}
			// 插入行政备案监督结果数据
			result = InspectService.adminInspect(ctx, params);
		} catch (Exception e) {
			e.printStackTrace();
			result = "{\"result\":\"0\",\"resultinfo\":\""+e.toString()+"\"}";
		}
		return result;
	}

	@Override
	public String adminInspectDelete(String param) {
		System.out.println("###adminInspectDelete### " + param);
		String result = "{\"result\":\"1\",\"resultinfo\":\"接口服务执行成功！\"}";
		try{
			result = InspectService.adminInspectDelete(ctx, param);
		} catch (Exception e) {
			e.printStackTrace();
			result = "{\"result\":\"0\",\"resultinfo\":\""+e.toString()+"\"}";
		}
		return result;
	}
}
